package com.example;

import org.apache.shiro.crypto.hash.Md5Hash;
import org.apache.shiro.crypto.hash.SimpleHash;

public class ShiroMD5 {
    public static void main(String[] args){
        //密码明文
        String password = "vespa";
        //使用MD5加密
        Md5Hash md5Hash1 = new Md5Hash(password);
        System.out.println("Md5加密=>"+md5Hash1);
        //Md5加盐,盐就是在密码明文后拼接新字符串，然后进行加密
        Md5Hash md5Hash2 = new Md5Hash(password,"pass");
        System.out.println("Md5带盐加密=>"+md5Hash2);
        //为了保证安全，避免被破解还可以多次迭代加密，保证数据安全
        Md5Hash md5Hash3 = new Md5Hash(password,"pass",3);//3次迭代加密
        System.out.println("Md5带盐3次迭代加密=>"+md5Hash3);

        //使用父类的带盐3次迭代加密  Md5Hash extends SimpleHash
        SimpleHash simpleHash = new SimpleHash("MD5",password,"pass",3);
        System.out.println("父类的带盐3次迭代加密 =>"+simpleHash);

    }
}
